package com.example.sports_meet.event;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;

import androidx.appcompat.app.AppCompatActivity;

import com.example.sports_meet.MyDbHelper;
import com.example.sports_meet.R;
import com.example.sports_meet.adapter.Select_Adapter;

import java.util.Objects;

public class event_del extends AppCompatActivity {

    private Button button;
    private ListView listView;
    private EditText editText;
    private Button button_search;
    private MyDbHelper myDbHelper;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_event_del);
        button = (Button) findViewById(R.id.button);
        Objects.requireNonNull(getSupportActionBar()).hide();
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });

        listView = findViewById(R.id.list_view);
        editText = findViewById(R.id.search);
        button_search = findViewById(R.id.button_search);

        myDbHelper = new MyDbHelper(this, "mydb", null, 1);
//        myDbHelper.insertFormData(myDbHelper.getWritableDatabase());
        Select_Adapter adapter = new Select_Adapter(this, myDbHelper, "eevent", "eno", true);
        listView.setAdapter(adapter);
        button_search.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String keyWord = editText.getText().toString();
                adapter.updateData("eevent", keyWord);
                adapter.notifyDataSetChanged();
            }
        });
    }
}